const {markedFetchYoudaoLijuMainMapEntryCollectionDAO} = require("./markedFetchYoudaoLijuMainMapEntryCollectionDAO-test");

markedFetchYoudaoLijuMainMapEntryCollectionDAO.connectThen((theCollection, client)=>{
    (async ()=>{


        let aggregated = await theCollection.aggregate(
            [
                // { $match: { fetchKeyWordsRaw: 'flee//v.' } },
                {
                    $lookup: {
                        from: 'markedFetchYoudaoLijuMainMapEntry',
                        localField: 'modifyBaseOn',
                        foreignField: '_id',
                        as: 'baseOn_mapping'
                    }
                },
                {
                    $set: {
                        baseOnFetchInfo: {
                            $first: '$baseOn_mapping'
                        }
                    }
                },
                {
                    $unset: [
                        'baseOnFetchInfo.resultLijuArr',
                        'modifyBaseOn',
                        'baseOn_mapping',
                        'resultLijuArr'
                    ]
                }
                // ,
                // {
                //     $project: {
                //         _id: 1,
                //         fetchKeyWordsRaw: 1,
                //         version: 1,
                //         baseOnFetchInfo: 1
                //     }
                // }
            ],
            { maxTimeMS: 60000, allowDiskUse: true }
        );


        // let arrResult = aggregated.toArray();
        // for await (const document of aggregated) {
        //     console.log(document);
        // }

        // console.log(arrResult);

        return await aggregated.toArray();
    })().then(result=>{
        console.log(result);
    })
})

